import {
  ChapterVideoList,
  courseItemsInterface,
  courseOutlineObject,
  courseParamsInterface,
} from '../models/courseModel';
import instance from '../utils/request';

interface data<T> {
  status: number;
  msg: string;
  data: T;
}

// 获取课程列表
export const getCourseListApi = (
  params: courseParamsInterface,
): Promise<data<{ total: number; data: courseItemsInterface[] }>> => {
  return instance.get('/course/list', { params });
};

// 根据课程id查询课程基本信息
export const getCourseInfoByIdApi = (
  courseId: number,
): Promise<data<courseOutlineObject>> => {
  return instance.get(`/course/getCourseInfo/${courseId}`);
};

// 根据课程id查询课程大纲列表
export const getChapterVideoByIdApi = (
  courseId: number,
): Promise<data<ChapterVideoList>> => {
  return instance.get(`/eduservice/chapter/getChapterVideo/${courseId}`);
};
